<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>${title }</title>
    <link rel="stylesheet" href="${basePath}/static/bootstrap/css/bootstrap.css"/>
    <link href="${basePath}/static/css/basic.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/login.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/list.css" rel="stylesheet" type="text/css">
    <script  type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
	<script  type="text/javascript" src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${basePath}/static/page/jqPaginator/jqPaginator.js"></script>
    <script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
    <link href="${basePath}/static/layer/layer_defined.css" rel="stylesheet" type="text/css">
    <style>
    .check_cl{
    width:15px;
    }
    </style>
</head>
<body>
<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

<!--内容部分-->
<div class="list_main lay_out" class="clearfix">
    <div class="list_DH">
        <%@include file="/WEB-INF/templates/common/indexPageAudit.jsp"%>
    </div>
    <div class="list_NR">
        <div class="loc">
            <h3 style="margin:0">主要诊断审核</h3>
        </div>
        <div class="list_con_table">
			<div class="search_table">
                <ul class="clearfix" style="margin-bottom:0;">
		<%-- 		    <li class="Label_1">病案号：&nbsp;</li>
				    <li class="Label_2"><input class="input_box" type="text"  name='onlyId' id='onlyId' value='' /></li>
				    <li class="Label_1">识别码：&nbsp;</li>
				    <li class="Label_2"><input class="input_box" type="text"  name='mrId' id='mrId' value='' /></li>
				    <li class="Label_1">姓名：&nbsp;</li>
				    <li class="Label_2"><input class="input_box" type="text"  name='name' id='name' value='' /></li>
				    <li class="Label_1">身份证号：&nbsp;</li>
				    <li class="Label_2"><input class="input_box" type="text"  name='idCard' id='idCard' value='' /></li>
				    <li class="Label_1">出院科室：&nbsp;</li>
				    <li class="Label_2">
				         <select class="input_box" id="outHospitalOfficeId">
	               		<option value="">请选择科室</option>
	               		<c:forEach var="office" items="${officeList }"> 
	               			<option value="${office.id }">${office.name}</option>
	               		</c:forEach>
	                	
	                	</select>
				    </li> --%>
				    <li class="Label_1" style="width:15%">出院日期：&nbsp;</li>
				    <li class="Label_2" style="width:85%;text-align:left;">
                    	&nbsp;&nbsp;<input class="input_box" style="width:20%;" type="text"  name='startTime' id='startTime' value='' onFocus="WdatePicker()" />
                    	<span>&nbsp;-&nbsp;</span><input class="input_box" type="text" style="width:20%;"  name='endTime' id='endTime' value='' onFocus="WdatePicker()" />
	                </li>
	
				    
				    <li class="Label_5">
				     	 <a onclick="searchQua()">查询</a>
				     	 <!-- <a href="javascript:exportMainAuditToExcel()">导出</a> -->
				    </li>
   				 </ul>
   			</div>
        </div>
    </div>
</div>
<!------页脚部分--------->
<%@include file="/WEB-INF/templates/common/footer.jsp"%>

<script>
	function searchQua(){
		var startTime=$("#startTime").val();
		var endTime=$("#endTime").val();
		if(!startTime && !endTime){
			layer.alert("请输入查询条件!",{icon:7});
			return;
		}
		
		window.open("${basePath}/audit/mainDiagnosisAudit?startTime="+startTime+"&endTime="+endTime+"",
 				'_blank',
 				"toolbar=yes,resizable=1, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=yes, width=800, height=600"); 
	}
	
}
function searchQua(){
	queryQua(1,20);
}

function queryQua(pageNum,pageSize){
	var onlyId=$("#onlyId").val();
	var mrId=$("#mrId").val();
	var name=$("#name").val();
	var idCard=$("#idCard").val();
	var outHospitalOfficeId=$("#outHospitalOfficeId").val();
	var outHospitalStartTime=$("#outHospitalStartTime").val();
	var outHospitalEndTime=$("#outHospitalEndTime").val();
	
	if((outHospitalOfficeId==null || outHospitalOfficeId=="") &&(mrId==null || mrId=="") &&(onlyId==null || onlyId=="") &&(outHospitalStartTime==null || outHospitalStartTime=="") && (outHospitalEndTime==null || outHospitalEndTime=='') && (name==null || name=='') && (idCard==null || idCard=='')){
		layer.alert("请输入查询条件!",{icon:7});
		return;
	}
	$.ajax({
		type:"post",
		url:"${basePath}/audit/getApprovalDateBirthPage",
		data:{idCard:idCard,name:name,onlyId:onlyId,mrId:mrId,outHospitalOfficeId:outHospitalOfficeId,outHospitalStartTime:outHospitalStartTime,outHospitalEndTime:outHospitalEndTime,pageNo:pageNum,pageSize:pageSize},
		beforeSend:function(){
			$("#tbody").html("");
			$("#loading").show();
		},
		success:function(data){
			console.log(data) 
			$("#tbody").html("");
			$("#loading").hide();
		 	if(data.success){
				var dataList=data.data.list;
				var Count=data.data.totalCount;
				if(dataList.length>0){
					var html="";
					page(pageNum,Count,pageSize);
				    for(var i=0;i<dataList.length;i++){
						var onlyId=dataList[i].onlyId?dataList[i].onlyId:"";
					    var mrId=dataList[i].mrId?dataList[i].mrId:"";
					    var name=dataList[i].name?dataList[i].name:"";
					    var outHospitalDate=dataList[i].outHospitalDate?dataList[i].outHospitalDate:"";
					    var officeName=dataList[i].outDeptName?dataList[i].outDeptName:"";
					    var defect=dataList[i].defect?dataList[i].defect:"";
						html+=" <tr data-guid="+dataList[i].firstGuid+" data-id="+dataList[i].disadvertageId+">"+
						     /*  '      <td class="tdLabel_5"><input type="checkbox" class="check_cl"></td>'+ */
				              "      <td class='tdLabel_5'>"+onlyId+"</td>"+
				              "      <td class='tdLabel_5'>"+mrId+"</td>"+
				              "      <td class='tdLabel_5'>"+name+"</td>"+
				              "      <td class='tdLabel_5'>"+outHospitalDate+"</td>"+
				              "      <td class='tdLabel_5'>"+officeName+"</td>"+
				              "      <td class='tdLabel_5'>"+defect+"</td>"+
				              "      <td class='tdLabel_5'><a class='btn_qx' style='padding:0px 5px 3px' onclick='pic(this)'>图片</a> <a class='btn_qx' style='padding:0px 5px 3px' onclick='scan(this)'>查看</a>"+
			                  "      <a class='btn_qx' style='padding:0px 5px 3px' onclick='check(this)'>审核</a>"+
			                  "      </td>"+
				              "  </tr>";
					}
					
					$("#tbody").html(html);
				}else{
					layer.alert('查询数据为空!', {icon: 5});
				    $("#tbody").html("");
                    $("#currentPage").html("0/0");
					$("#totalPage").html("0");
					$("#page_plus").html("");	 
				} 
			}else{
				layer.alert(data.msg, {icon: 5});
				$("#tbody").html("");
				$("#currentPage").html("0/0");
				$("#totalPage").html("0");
				$("#page_plus").html("");
			}
		}
	})
	
}

 function page(currentPage,totalCounts,pageSize){
	   /*  var pageSize=1; */
        var visiblePages = 10;
        var totalPages = Math.ceil(totalCounts/pageSize);
        $('#page_plus').jqPaginator({
            totalCounts: totalCounts,
            pageSize:pageSize,
            visiblePages: visiblePages,
            currentPage: currentPage,

            first:'<li class="first"><a href="javascript:void(0);">首页</a></li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
            last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
            onPageChange: function (num,type) {
          
            	 if(type !='init'){
                 
            		 queryQua(num,pageSize);
                 }
            	
                $("#totalPage").html(totalCounts);
                $("#currentPage").html(num+"/"+totalPages);
            }
        });

    }
 
 
 //查看按钮事件
 function scan(event){
	 var target=$(event);
	 var guid=target.closest("tr").attr("data-guid");
	 window.open('${corePath}/medrecord/medrecordHomePageManage?firstGuid='+guid);
 }
 //图片按钮事件
 function pic(event){
	 var target=$(event);
	 var guid=target.closest("tr").attr("data-guid");
	 window.open('${basePath}/borrow/showMedrecordMarkImage?firstGuid='+guid);
 }
//审核按钮事件
 function check(event){
	 var target=$(event);
	 var guid=target.closest("tr").attr("data-guid");
	 var id=target.closest("tr").attr("data-id");
	 location='${basePath}/statics/auditDetail?firstGuid='+guid+"&auditDicId="+id;
 }
</script>
</body>
</html>